<%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/tld/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean"%>

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Login</title>
<link rel="stylesheet" type="text/css" href="css/FinalProjectCSS.css"/>
<script type="text/javascript">
	//slight update to account for browsers not supporting e.which
	function disableF5(e, task) { 
		if ((e.which || e.keyCode) == 116) {
			if((document.forms[0].task.value.indexOf("insert") != -1) || 
				(document.forms[0].task.value.indexOf("update") != -1) ||
				(document.forms[0].task.value.indexOf("delete") != -1))	{
				e.preventDefault(); 
				document.forms[0].task.value = task;
				document.forms[0].submit();
			}		
		}
	}

	function login() {
		document.forms[0].task.value = "logincheck";
		document.forms[0].submit();
	}
	
	function enterPress(e){
		var code = (e.keyCode ? e.keyCode : e.which);
		if(code == 13) {
		login();
		}
	}
</script>
</head>
<body onKeyPress="enterPress(event)" onkeydown="javascript:disableF5(event, '');">
<center>
	<br><br><br><br>
	<html:form action="/Login" method="post">
	<html:hidden property="task" name="loginForm"/>
		<table width="450px" class="boxShadow">
			<tr>
				<td align="center" class="headerBox blueBackground" style="color:black;">Login</td>
			</tr>
			<tr>
				<td style="vertical-align: middle; height:125px;">
					<table align="center" style="border-spacing: 3px;">			
						<tr>
							<td width="70px" style="vertical-align: middle;">Username</td>
							<td><html:text styleClass="textMedium" property="username" name="loginForm"></html:text></td>
						</tr>
						<tr>
							<td style="vertical-align: middle;">Password</td>
							<td><html:password styleClass="textMedium" property="password" name="loginForm"></html:password></td>
						</tr>
						<tr>
							<td colspan="2" height="5px"></td>
						</tr>
						<tr>
							<td colspan="2" align="center">
								<input type="button" value="Submit" class="buttonStyle" onclick="javascript:login()"/>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>		
	</html:form>
</center>
</body>
</html>

<%
	if(session != null){
		if(session.getAttribute("result") != null)
		{
			String message = session.getAttribute("result").toString();
			%>
				<script type="text/javascript">
					window.alert('<%=message%>');
				</script>
			<%
			session.removeAttribute("result");
		}	
	}
%> 